package com.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.db.domain.Courier;
import com.mall.db.service.CourierService;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/cc")
public class CourierController extends BaseController{

    @Resource(name = "courierService")
    private CourierService cs;

    @RequestMapping("/order/find")
    public Map<String, Object> orderFind(Courier courier) {
        PageHelper.startPage(courier.getPage(),courier.getLimit());
        QueryWrapper qw=new QueryWrapper();
        if(!StringUtils.isEmpty(courier.getId())) {
            qw.eq("id",courier.getId());
        }
        List<Courier> list=cs.list(qw);
        PageInfo<Courier> page=new PageInfo<>(list,courier.getLimit());
        return findMap(page.getList(),page.getTotal());
    }

    @RequestMapping("/order/addOne")
    public Integer addOne(Courier courier) {
        Integer i = cs.addOne(courier);
        i = courier.getId();
        return i;
    }
}
